﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SuperQuiz.Logic;
using Windows.Globalization;

namespace SuperQuiz.QualityChecklist
{
    public class QualityChecklistApplication : QuizApplication
    {
        public override void Initialize()
        {
            HomePageType = typeof(QuizPage);
            HomePageParameter = "AELChecklist";
            ApplicationLanguages.PrimaryLanguageOverride = "pt-br";
        }

        protected override async Task LoadQuizzes()
        {
            await LoadQualityChecklistQuiz();
        }

        private async Task LoadQualityChecklistQuiz()
        {
            var categories = await SuperQuiz.QualityChecklist.QualityChecklistDataSource.LoadQualityChecklistQuiz();
            foreach (var category in categories)
            {
                QuizCategories.Add(category);
                CategoryDictionary[category.UniqueId] = category;
                foreach (var quiz in category.Quizzes)
                {
                    QuizDictionary[quiz.UniqueId] = quiz;
                    foreach (var question in quiz.Questions)
                    {
                        question.Quiz = quiz;
                    }
                }
            }
        }

        protected override QuizPlay CreateQuizPlay()
        {
            return new QualityChecklistQuizPlay();
        }
    }
}
